package logic

import (
	"context"
	"store-kit/models/mysql"
	"store-kit/storerpc/internal/svc"
	"store-kit/storerpc/storerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UploadLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogic {
	return &UploadLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UploadLogic) Upload(in *storerpc.UploadRequest) (*storerpc.UploadResponse, error) {
	// todo: add your logic here and delete this line

	store := mysql.Store{
		Name: in.Name,
		Num:  int(in.Num),
	}

	mysql.DB.Debug().Updates(&store)

	return &storerpc.UploadResponse{
		StoreId: int64(store.ID),
	}, nil
}
